import { Injectable } from '@angular/core';
import { Store } from '@ngxs/store';
import { MessageSelector } from '@shared/lib/store/message/message.selector';
import { LogisticsAction } from './store/logistics.action';

@Injectable({
  providedIn: 'root',
})
export class LogisticsService {

  constructor(
      private store: Store,
  ) {
  }

  init() {
    this.store.select(MessageSelector.msg).subscribe(r => {
      if (!r) return;
      if ('Shop_GotoCheckout' === r.key) this.store.dispatch([new LogisticsAction.GetBillMessage(r.data)]);
    });
  }
}
